const express = require('express');

const bodyParser = require('body-parser');

let app = express();

// 需要用到一个中间件
// extended:false
// app.use(express.urlencoded({extended:false}));


// 方式二
app.use(bodyParser.urlencoded({extended:false}));

app.post('/userPost',(req,res)=>{

    // 获取请求体数据 - 必须使用中间件 express.urlencoded
    // console.log(req.body); //undefined

    console.log(req.body); //[Object: null prototype] { username: 'xiaoli', age: '88' }


    console.log(req.body.username); //xiaoli

    // console.log("进来了");

    res.end('end');

})


app.listen(80,()=>{
    console.log('success');
})